package com.zlkj.pro.config.web;

import com.fasterxml.jackson.databind.ObjectMapper;
import com.zlkj.pro.core.serializer.VoSerializer;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter;

/**
 * @author 孙铭泽
 * @date 2020-10-29
 * @time 16:20
 **/
@Configuration
public class HttpMessageConverter {

    @Bean
    public MappingJackson2HttpMessageConverter mappingJackson2HttpMessageConverter(ObjectMapper objectMapper) {
        MappingJackson2HttpMessageConverter mappingJackson2HttpMessageConverter = new MappingJackson2HttpMessageConverter();
        objectMapper.setSerializerFactory(objectMapper.getSerializerFactory().withSerializerModifier(new VoSerializer()));
        mappingJackson2HttpMessageConverter.setObjectMapper(objectMapper);
        return mappingJackson2HttpMessageConverter;
    }

}
